<?php
namespace Home\Controller;
use Think\Controller;
class IndexController extends Controller {
    public function qrCodeAdmin(){
        $this->qrcode=M('weixin_qrcode')->select();
        $this->display();
    }
    public function userAuth(){
        if(!IS_AJAX) $this->redirect('http://www.weirongm.com/');
        $id = 'anqiang2015';
        $pwd = 'weirongZHILIAN';
        $post_id = I('id');
        $post_pwd = I('pwd');
        if($post_id == $id && $post_pwd == $pwd){
            session('username','anqiang2015');
            $this->ajaxReturn('1','EVAL');
        }else{
            $this->ajaxReturn('0','EVAL');
        }
    }
    public function qrcodeAdd(){
        $data = array(
            's_id' => I('s_id'),
            's_name' => I('s_name'),
            's_c' => I('s_c'),
            'open_weixin' => I('s_weixin'),
            's_phone' => I('s_phone'),
            'time' => time()
        );
        $result = M('weixin_qrcode')->data($data)->add();
        if($result){
            $this->ajaxReturn('1','EVAL');
        }else{
            $this->ajaxReturn('0','EVAL');
        }
    }
    public function qrcodeUpdate(){
        $data = array(
            's_id' => I('s_id'),
            's_name' => I('s_name'),
            's_c' => I('s_c'),
            'open_weixin' => I('s_weixin'),
            's_phone' => I('s_phone'),
            'time' => time()
        );
        $id = array(
          'id' => I('id')
        );
        $result = M('weixin_qrcode')->where($id)->save($data);
        if($result){
            $this->ajaxReturn('1','EVAL');
        }else{
            $this->ajaxReturn('0','EVAL');
        }
    }
}
